package com.groupbuying.settleconsumer.service.impl.channel;

import com.groupbuying.settleconsumer.common.ChannelServiceStrategyFactory;
import com.groupbuying.settleconsumer.constants.PayInfoEnumConstants;
import com.groupbuying.settleconsumer.constants.SettleUshopSplitChannleEnumConstants;
import com.groupbuying.settleconsumer.constants.SettleUshopSplitSubsidiesRatioEnumConstants;
import com.groupbuying.settleconsumer.service.ChannelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class YsChannelService implements ChannelService,InitializingBean {

    public static final Logger logger = LoggerFactory.getLogger(YsChannelService.class);

    @Override
    public void afterPropertiesSet() throws Exception {
        ChannelServiceStrategyFactory.register(PayInfoEnumConstants.ENUM_PAYCHANNEL_YS,this);
    }

    @Override
    public Map<String, BigDecimal> getChannelRate() {
        BigDecimal channleRatio = new BigDecimal(SettleUshopSplitChannleEnumConstants.YS_RATIO);
        BigDecimal subsidiesRatio = new BigDecimal(SettleUshopSplitSubsidiesRatioEnumConstants.YS_RATIO);
        Map<String,BigDecimal> result = new ConcurrentHashMap<>();
        result.put("channleRatio",channleRatio);
        result.put("subsidiesRatio",subsidiesRatio);
        return result;
    }
}
